﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Open_MUD.Kernel.Utils;
using System.Net.Sockets;
using System.Net;
using Open_MUD.Kernel.Interface.Conns;

namespace Open_MUD.Kernel.Server.Daemon
{
    class TelnetDemon
    {
        const int BacklogSize = 60;

        public void Start()
        {
            Log.getInstance().log("Iniciando Demonio Telnet");
            Socket server = new Socket(AddressFamily.InterNetwork,
            SocketType.Stream, ProtocolType.Tcp);
            int port = Config.getInstance().getIntValue("Kernel","puerto");
            server.Bind(new IPEndPoint(IPAddress.Any, port));
            server.Listen(BacklogSize);
            Log.getInstance().log("Aceptando conexiones por el puerto " + port.ToString() );
            while (true)
            {
                Socket conn = server.Accept();               
                new TelnetConnection(conn);
            } 
        }
    }
}
